//
//  ShowImageCell.m
//  SweetComics
//
//  Created by LeeZhe on 15/1/29.
//  Copyright (c) 2015年 LeeZhe. All rights reserved.
//

#import "ShowImageCell.h"
#import "UIImageView+WebCache.h"
@implementation ShowImageCell
@synthesize imageView;
@synthesize titleLabel;
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
//        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(action:)];
//        self.indexPath = [[NSIndexPath alloc] init];

        imageView = [[UIImageView alloc] init];
        [self.contentView addSubview:imageView];
//        [imageView addGestureRecognizer:tap];
//        [imageView setUserInteractionEnabled:YES];
        titleLabel = [[UILabel alloc] init];
        titleLabel.textColor = [UIColor purpleColor];
        
        [self.contentView addSubview:titleLabel];
    }
    return self;
}

- (void)setComicsCell:(ComicList *)comics{
    if (_comics != comics) {
        [_comics release];
        _comics = [comics retain];
    }
//    NSLog(@"%@ ~~~~~~~~~~",comics.title);
    titleLabel.text = comics.title;
    NSURL *url = [NSURL URLWithString:comics.cover_url];
    [imageView setImageWithURL:url];
    
}



/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */
-(void)layoutSubviews
{
    [super layoutSubviews];
//    self.contentView.frame = CGRectMake(20, 20,self.frame.size.width, self.frame.size.height);
    imageView.frame = CGRectMake(0.0,1.0,self.contentView.frame.size.width, self.contentView.frame.size.height);
    NSLog(@"contentView %f",self.contentView.frame.size.height);
    titleLabel.frame = CGRectMake(0.0f,self.contentView.self.frame.size.height,self.contentView.frame.size.width - 6,30);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.font = [UIFont systemFontOfSize:9];
    self.titleLabel.textColor = [UIColor blackColor];
    
}

@end
